package com.eastfair.venueservice.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 借用归还记录
 * </p>
 *
 * @author linan
 * @date 2022-09-19
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "ServiceBorrowReturnGoodsLossStateEnum", description = "物资完损状态 #{SEVERE_DAMAGE:严重损坏;PARTIAL_DAMAGE:部分损坏;SLIGHT_DAMAGE:轻微损坏;UNDAMAGED:未损坏-枚举")
public enum ServiceBorrowReturnGoodsLossStateEnum implements BaseEnum {

    /**
     * SEVERE_DAMAGE="严重损坏"
     */
    SEVERE_DAMAGE("严重损坏"),
    /**
     * PARTIAL_DAMAGE="部分损坏"
     */
    PARTIAL_DAMAGE("部分损坏"),
    /**
     * SLIGHT_DAMAGE="轻微损坏"
     */
    SLIGHT_DAMAGE("轻微损坏"),
    /**
     * UNDAMAGED="未损坏"
     */
    UNDAMAGED("未损坏"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static ServiceBorrowReturnGoodsLossStateEnum match(String val, ServiceBorrowReturnGoodsLossStateEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static ServiceBorrowReturnGoodsLossStateEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(ServiceBorrowReturnGoodsLossStateEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "SEVERE_DAMAGE,PARTIAL_DAMAGE,SLIGHT_DAMAGE,UNDAMAGED", example = "SEVERE_DAMAGE")
    public String getCode() {
        return this.name();
    }

}
